from pub.routine import UdpServer
from rcpm.protocal import RemoteFileTrans

RCP_PORT = 31616
APP_DESC = "Remote copy by Python3, without SSL [v0.1.2] 2019/10/26"

def run_server():
    def getopt():
        import argparse
        parser = argparse.ArgumentParser("rcpd", description=APP_DESC)
        parser.add_argument("-f", "--config", action="store_true", help="step into the config page")
        return parser.parse_args()

    args = getopt()
    if args.config:
        print("敬请期待")
        return

    server = UdpServer(RCP_PORT)
    protocal = RemoteFileTrans()
    server.set_protocal(protocal)
    server.listen()

    while True:
        data = input("Input the Data ([Q] for quit): ")
        if data == "Q":
            server.stop()  # 关闭监听
            break

if __name__ == "__main__":
    run_server()
